#include <iostream>
#include "Rngs.h"
using namespace std;
int main()
{
  
  RngBase *x;
  x = new NormalGen(2, 16);
  //  NormalGen z(2,16);
  double mean =0.0;
  double var = 0.0;
  int n = 10;
  double * a = new double [n];
  double * b = new double [n];

 

  for (int i=0; i< n; i++) {
    //    a[i] = z.genNext();
    a[i] = x->genNext();
    mean += a[i];
    var += a[i]*a[i];
    cout<<" "<<a[i]<<" ";
  }
  mean /= n;
  var = var/(n-1) - n/(n-1)*mean*mean;

  cout << "before restart" << endl;
  cout << "sample  mean[" << n << "] = " << mean << endl;
  cout << "sample  variance [" << n << "] = " << var << endl;
  //  z.restart();
  x->restart();
  //x->restartSub();

  for (int i=0; i< n; i++) {
    //    b[i] = z.genNext();
    b[i] = x->genNext();
    mean += b[i];
    var += b[i]*b[i];
    cout<<" "<<b[i]<<" ";
  }
  mean /= n;
  var = var/(n-1) - n/(n-1)*mean*mean;
  cout << "after restart" << endl;
  cout << "sample  mean[" << n << "] = " << mean << endl;
  cout << "sample  variance [" << n << "] = " << var << endl;
}
